﻿cmake_minimum_required(VERSION 3.5)

# 检查 VCPKG_ROOT 环境变量是否存在
if(DEFINED ENV{VCPKG_ROOT})
    # 如果环境变量存在，则设置 CMAKE_TOOLCHAIN_FILE 的默认值
    set(DEFAULT_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
else()
    # 如果环境变量不存在，设置默认值为空
    set(DEFAULT_TOOLCHAIN_FILE "" CACHE FILEPATH "<path_to_vcpkg>/scripts/buildsystems/vcpkg.cmake")
endif()

if(NOT DEFAULT_TOOLCHAIN_FILE)
    message(FATAL_ERROR "DEFAULT_TOOLCHAIN_FILE is not set. <path_to_vcpkg>/scripts/buildsystems/vcpkg.cmake")
endif()

# 指定vcpkg的工具链文件,在project函数之前
set(CMAKE_TOOLCHAIN_FILE ${DEFAULT_TOOLCHAIN_FILE} CACHE FILEPATH "Path to vcpkg toolchain file")

# 输出当前使用的工具链文件路径
message(STATUS "Using vcpkg toolchain file: ${CMAKE_TOOLCHAIN_FILE}")

PROJECT(
    VolumeRendering
    DESCRIPTION "体渲染"
)

set(CMAKE_CXX_STANDARD 17)

option(ENABLE_VOLUMERENDER "enable building VolumeRender" OFF)
option(ENABLE_VOLUMERENDER_ACCELERATE "enable building VolumeRender-Accelerate" ON)
option(ENABLE_DATASTATISTICS "enable building VolumeRender" OFF)
option(ENABLE_COLORTRANSFERFUCNTION "enable building ColorTransferFunction" OFF)
option(ENABLE_DICOMTORAW "enable building DicomToRaw" OFF)

if(ENABLE_VOLUMERENDER)
	add_subdirectory(VolumeRender)
endif()

if(ENABLE_VOLUMERENDER_ACCELERATE)
	add_subdirectory(VolumeRender-Accelerate)
endif()

if(ENABLE_DATASTATISTICS)
	add_subdirectory(DataStatistics)
endif()

if(ENABLE_COLORTRANSFERFUCNTION)
	add_subdirectory(ColorTransferFunction)
endif()

if(ENABLE_DICOMTORAW)
	add_subdirectory(DicomToRaw)
endif()

